import http from '@/http/api.js'

// 获取token
const token = (tenantId, username, password, type) => {
	return http.request({
		url: '/blade-auth/oauth/token',
		method: 'POST',
		header: {
			'Tenant-Id': tenantId,
			'Authorization':'Basic cmlkZXI6cmlkZXJfc2VjcmV0'
		},
		params: {
			tenantId,
			username,
			password,
			grant_type: "password",
			scope: "all",
			type
		}
	})
}

// 获取用户信息
const userInfo = () => {
	return http.request({
		url: '/v2/info',
		method: 'GET',
	})
}

// 用户登录
const login = (data) => {
	return http.request({
		url: '/v2/login',
		method: 'POST',
		data: data
	})
}
// 用户注册
const register = (data) => {
	return http.request({
		url:'/v2/register',
		method: 'POST',
		data: data
	})
}

// 发送手机验证码
const sms = (phone) => {
	return http.request({
		url:'/v2/ssmcode',
		method: 'POST',
		data: {
			phone: phone
		}
	})
}

export default {
	token,
	userInfo,
	login,
	register,
	sms
}
